import requests
import json

userId1 = "1LYvjqt2-HKaiNntwTI_dQ2"
authtoken1 = "xmMTwLiXU%2BMcUCZyysiqHrzHMB40rXHmZlaD8dDLbRJDPoJOlA95gAHqvdt78G9iszh18Tmjb9Mx08F5b8o6%2BCVklFrHN8WNdRwEVnPdaz27Pm%2F%2FnDVj2rMtCMeXVG3vm7uCnk07tNcf3sxawSzdJ28rezMPwkamh6jAu8JTfrABx1hTVj1%2BuME0QsVv17wY%2CMatchFD51DE89D449%2C12%2C49"
userId2 = "CXB9UEXqP2IGb5U0-QVGBA2"
authtoken2 = "7nHYc6yoEjJqQnX%2Bf2fKmPEzg1MBNRa8xwjH0K6%2FMOigd4g9767JJxQ4tcUzzbzh9GVVbVHUIgzsK6LERaO6R9GEyJbE0wYQqFARc%2BlDCbrA%2FguD0OnfN01PxaLPoeWzYpU%2BoJR6PcNcKuNcZ6GAKj%2Bc9k3Ycs4w86L2N4AdUEAGw9vtKLl5m2a%2F1a6eXoXp%2CMatchFD51DE89D449%2C12%2C49"
userId = userId2
authtoken = authtoken2


def main():
    import requests
    import json

    headers = {
        "accept": "*/*",
        "accept-language": "zh-CN,zh;q=0.9",
        "cache-control": "no-cache",
        "content-type": "application/json",
        "origin": "https://jp.match.com",
        "pragma": "no-cache",
        "priority": "u=1, i",
        "referer": "https://jp.match.com/profile/me/edit",
        "sec-ch-ua": "\"Google Chrome\";v=\"125\", \"Chromium\";v=\"125\", \"Not.A/Brand\";v=\"24\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
    }
    cookies = {
        # "machineid": "22A8E804-1AE8-41A2-9B25-8620ECE8A0AD",
        # "_csrf": "UJcM1TwShGkcCroHNxKnfCpG",
        # "OptanonAlertBoxClosed": "2024-05-21T03:44:52.498Z",
        # "_gcl_au": "1.1.628892699.1716263093",
        # "__lt__cid": "ff4b201b-5dbc-4c64-bebf-f66b99ab8aeb",
        # "_yjsu_yjad": "1716263094.ed9f0d29-68b4-4c75-a103-858ce2973f32",
        # "Password": "Lfr6B9WFFbBSvmTflhYESg2",
        # "Handle": "3b8qCJh6fMyeUzJnFRbMLoREuBd9a0hMBw7a_NRSJ11nf1YD0auddQ2",
        # "uid": "1LYvjqt2-HKaiNntwTI_dQ2",
        # "cc": "109",
        # "searchimpressions": "%7B%22s%22%3A14%2C%22p%22%3A%5B2%5D%7D",
        "authtoken": authtoken,
        # "searchparams": "%7B%22gender%22%3A1%2C%22seekingGender%22%3A2%2C%22minAge%22%3A25%2C%22maxAge%22%3A35%2C%22postalCode%22%3A%2290210%22%2C%22distance%22%3A50%2C%22isOnlineNow%22%3Afalse%2C%22withPhotos%22%3Atrue%2C%22certifiedOnly%22%3Afalse%2C%22availableForChat%22%3Afalse%7D",
        # "__lt__sid": "2f18bff1-298e6708",
        # "FCNEC": "%5B%5B%22AKsRol_40AJVDz9r_Y6csD66coLZ5kp9PieHUmsGnKSl8V9OsIBZm02HQx_w0yxrfJSackBMausYFVsdkILw8YJE141dCl0fGultT09Afz-i2P9QZS-1BnPv9vByo3kboUzL2g5sC2T4OyeU_Y4HrzBz2qCNs9g9WQ%3D%3D%22%5D%5D",
        # "ADRUM": "s=1716271627966&r=https%3A%2F%2Fjp.match.com%2Fprofile%2Fme%2Fedit%3F0",
        # "RT": "\"sl=0&ss=1716271124580&tt=0&obo=0&bcn=%2F%2F17de4c0f.akstat.io%2F&sh=&dm=match.com&si=dc458eef-85a5-4a9d-9f5b-9f278116964f\"",
        # "OptanonConsent": "isGpcEnabled=0&datestamp=Tue+May+21+2024+14%3A07%3A13+GMT%2B0800+(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)&version=6.39.0&isIABGlobal=false&hosts=&consentId=68df14c2-7844-47ab-9dcc-7c675e41e12d&interactionCount=1&landingPath=NotLandingPage&groups=1%3A1%2C2%3A1%2C3%3A1%2C4%3A1&geolocation=%3B&AwaitingReconsent=false",
        # "ADRUM_BT": "R:36|i:375448|g:5ebdf56f-c758-4633-b735-502dd1ec3e7525172660|e:47|n:matchcom_1a7e9d7a-2e56-4fa7-93ca-81d5e14cf768"
    }
    url = "https://jp.match.com/graphql"
    data = {
        "operationName": "ProfileEdit",
        "variables": {
            "userId": userId,
            "isMetric": True
        },
        "query": "query ProfileEdit($userId: String!, $isMetric: Boolean) {\n  profileEdit(userId: $userId, isMetric: $isMetric) {\n    ...ProfileEdit_LayoutData\n    __typename\n  }\n}\n\nfragment ProfileEdit_LayoutData on Profile {\n  id\n  userId\n  primaryPhoto {\n    id\n    uri\n    __typename\n  }\n  ...Profile_AccountInfo\n  ...Profile_ProfileAttributeData\n  ...Profile_SelfInfo\n  self {\n    ...ProfileEdit_EssayData\n    __typename\n  }\n  seek {\n    ...Profile_SeekSummary\n    __typename\n  }\n  photos {\n    ...Profile_Photos\n    __typename\n  }\n  userCertifications {\n    ...User_Certifications\n    __typename\n  }\n  __typename\n}\n\nfragment Profile_ProfileAttributeData on Profile {\n  profileQueueStatus\n  hasUpgradedEnhancedInterests\n  self {\n    college {\n      id\n      name\n      __typename\n    }\n    schools {\n      id\n      userId\n      schoolId\n      schoolName\n      educationLevel\n      __typename\n    }\n    hometown {\n      id\n      cityCode\n      displayName\n      __typename\n    }\n    height\n    id\n    essays {\n      id\n      essayId\n      text\n      approvalStatus\n      __typename\n    }\n    trendingEssays {\n      id\n      essayId\n      text\n      approvalStatus\n      __typename\n    }\n    pendingEssays {\n      id\n      essayId\n      text\n      approvalStatus\n      __typename\n    }\n    pendingTrendingEssays {\n      id\n      essayId\n      text\n      approvalStatus\n      __typename\n    }\n    attributes {\n      id\n      attributeId\n      answerIds\n      answersData {\n        id\n        answerId\n        answerText\n        __typename\n      }\n      weight\n      __typename\n    }\n    __typename\n  }\n  seek {\n    id\n    uHeight\n    lHeight\n    ageWeight\n    heightWeight\n    distanceWeight\n    attributes {\n      id\n      attributeId\n      answerIds\n      answersData {\n        id\n        answerId\n        answerText\n        __typename\n      }\n      weight\n      __typename\n    }\n    __typename\n  }\n  __typename\n}\n\nfragment Profile_AccountInfo on Profile {\n  handle\n  id\n  self {\n    age\n    id\n    __typename\n  }\n  __typename\n}\n\nfragment Profile_SelfInfo on Profile {\n  self {\n    id\n    gender\n    location {\n      id\n      fullName\n      country {\n        id\n        name\n        shortName\n        __typename\n      }\n      state {\n        id\n        name\n        shortName\n        __typename\n      }\n      city {\n        id\n        name\n        shortName\n        __typename\n      }\n      postalCode\n      __typename\n    }\n    hometown {\n      id\n      cityCode\n      displayName\n      __typename\n    }\n    __typename\n  }\n  __typename\n}\n\nfragment Profile_SeekSummary on ProfileSeek {\n  id\n  lAge\n  uAge\n  ageWeight\n  heightWeight\n  distanceWeight\n  gender\n  location {\n    id\n    fullName\n    city {\n      id\n      name\n      __typename\n    }\n    state {\n      id\n      name\n      shortName\n      __typename\n    }\n    country {\n      id\n      name\n      shortName\n      __typename\n    }\n    postalCode\n    __typename\n  }\n  photosOnly\n  withinRadius\n  __typename\n}\n\nfragment ProfileEdit_EssayData on ProfileSelf {\n  essays {\n    id\n    essayId\n    text\n    approvalStatus\n    __typename\n  }\n  pendingEssays {\n    id\n    essayId\n    text\n    approvalStatus\n    __typename\n  }\n  __typename\n}\n\nfragment Profile_Photos on ProfilePhotosCollection {\n  id\n  totalItems\n  items {\n    ...Profile_PhotosPhoto\n    __typename\n  }\n  __typename\n}\n\nfragment Profile_PhotosPhoto on ProfilePhoto {\n  id\n  approvalStatus\n  captionApprovalStatus\n  caption\n  isPrimary\n  ordinal\n  uri\n  isPrimaryCapable\n  __typename\n}\n\nfragment User_Certifications on UserCertificateCollection {\n  id\n  maxResults\n  totalItems\n  items {\n    id\n    certificateId\n    certificateType\n    approvalStatus\n    isVisible\n    uploadDate\n    rejectDate\n    approveDate\n    userId\n    __typename\n  }\n  __typename\n}\n"
    }
    data = json.dumps(data, separators=(',', ':'))
    response = requests.post(url, headers=headers, cookies=cookies, data=data)

    if response.status_code != 200:
        print("未知错误")
        print(response.text)
        return
    try:
        res = response.json()
        approvalStatus = res['data']['profileEdit']['userCertifications']['items'][0]['approvalStatus']
        print(approvalStatus)
        return approvalStatus
    except:
        print("未知错误2")
        print(response.text)
        return


if __name__ == '__main__':
    main()
